import http from '@/utils/http'

const BASE_URL = '/testing/reportDetailApi'

export interface ReportDetailApiResp {
  id: string
  reportId: string
  executeState: string
  assertionState: string
  exceptionMsg: string
  expendTime: string
  requestHeader: string
  requestQuery: string
  requestBody: string
  responseHeader: string
  responseBody: string
  environmentId: string
  caseId: string
  num: string
  name: string
  description: string
  assertion: string
  relation: string
  path: string
  method: string
  query: string
  header: string
  body: string
  bodyType: string
  version: string
  status: string
  isDeleted: string
  createdBy: string
  updatedBy: string
  createdAt: string
  updatedAt: string
  createUserString: string
  updateUserString: string
}
export interface ReportDetailApiDetailResp {
  id: string
  reportId: string
  executeState: string
  assertionState: string
  exceptionMsg: string
  expendTime: string
  requestHeader: string
  requestQuery: string
  requestBody: string
  responseHeader: string
  responseBody: string
  environmentId: string
  caseId: string
  num: string
  name: string
  description: string
  assertion: string
  relation: string
  path: string
  method: string
  query: string
  header: string
  body: string
  bodyType: string
  version: string
  status: string
  isDeleted: string
  createdBy: string
  updatedBy: string
  createdAt: string
  updatedAt: string
  createUserString: string
  updateUserString: string
}
export interface ReportDetailApiQuery {
  version: string
  createdBy: string
  sort: Array<string>
}
export interface ReportDetailApiPageQuery extends ReportDetailApiQuery, PageQuery {}

/** @desc 查询接口测试报告列表 */
export function listReportDetailApi(query: ReportDetailApiPageQuery) {
  return http.get<PageRes<ReportDetailApiResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询接口测试报告详情 */
export function getReportDetailApi(id: string) {
  return http.get<ReportDetailApiDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增接口测试报告 */
export function addReportDetailApi(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改接口测试报告 */
export function updateReportDetailApi(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除接口测试报告 */
export function deleteReportDetailApi(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出接口测试报告 */
export function exportReportDetailApi(query: ReportDetailApiQuery) {
  return http.download<any>(`${BASE_URL}/export`, query)
}
